package Day014_Lambda表达式_Stream流.ZuoYe.Test4;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;

/**
 * @author zhangyan
 * @date 2020/5/5 18:25
 */
public class Test2 {
    public static void main(String[] args) {

        //创建集合
        List<String> list = new ArrayList<>();
        list.add("陈玄风");
        list.add("梅超风");
        list.add("陆乘风");
        list.add("曲灵风");
        list.add("武眠风");
        list.add("冯默风");
        list.add("罗玉风");
        //获取Stream流
        Stream<String> stream = list.stream();
        //取出前两个元素
        Stream<String> limit = stream.limit(2);
        limit.forEach((e)->{
            System.out.println(e);
        });

        Stream<String> stream1 = list.stream();
        //取出后两个元素
        Stream<String> skip = stream1.skip(5);
        skip.forEach((e)->{
            System.out.println(e);
        });
    }
}
